import Vue from 'vue'
import VueRouter from 'vue-router'
// import Tokenrefresh from '../api/Tokenrefresh/Tokenrefresh.js'
// 登入
import About from '../views/About/About.vue'
// 首页
import Home from '../views/Home/Home.vue'
import dashboard from '../views/dashboard/dashboard.vue'
import Refresh from '../views/Refresh/Refresh.vue'
// 运营管理
import operate from './operate.js'
// 商品管理
import goods from './goods.js'
// 推广管理
import promotion from './promotion.js'
// 系统管理
import system from './system.js'
Vue.use(VueRouter)

// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location, onResolve, onReject) {
// if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
// return originalPush.call(this, location).catch(err => err)
// }
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    redirect: '/About'
  },
  {
  	path: '/About',
  	component: About
  },
  {
    path: '/Home',
    name: Home,
    component: Home,
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: '首页',
        component: dashboard
      },
      {
        path: '/Refresh',
        name: '首页',
        component: Refresh
      }
    ]
  },

  // 运营管理
  	operate,
  // 商品管理
  goods,
  // 推广管理
  promotion,
  // 系统管理
  system

]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
